package demo1;

public class Student implements Comparable<Student> {
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return 0;
    }


    //@Override
    /*public int compareTo(Student o) {
        return this.name.compareTo(o.name);//姓名排序，以为String有compareTo接口，可以直接调用
        *//*if (this.age > o.age) {
            return 1;
        } else if (this.age == o.age) {
            return 0;
        } else {
            return -1;
        }*//*
        //return this.age - o.age;//从大到小
        //return this.age.compareTo(o.age);
        //return o.age - this.age;//从小到大
    }*/
}
